package com.crr.service.impl;

import com.crr.mapper.AccountMapper;
import com.crr.service.AccountService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

@Service
@Slf4j
public class AccountServiceImpl implements AccountService {
    @Resource
    private AccountMapper accountMapper;

    @Override
    public void decrease(Long userId, Long money) {
        log.info("-----------修改账户余额");
        accountMapper.decrease(userId, money);
        //myTimeout();
      //int num=10/0;
        log.info("-----------修改账户余额成功");
    }

    private static void myTimeout() {
        try {
            TimeUnit.SECONDS.sleep(65);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
